# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License, v2 or later
# $Header: $

# If we have a current-user-vm (and aren't alien)... set it to JAVA_HOME
gentoo_user_vm="${HOME}/.gentoo/alice/alien"
gentoo_system_vm="/etc/alice/alien"

unset ALIEN_DIR
unset X509_CERT_DIR
unset GSHELL_ROOT
unset GSHELL_NO_GCC

if [ -z "${UID}" ] ; then
	# id lives in /usr/bin which might not be mounted
	if type id >/dev/null 2>/dev/null ; then
		user_id=$(id -u)
	else
		[ "${USER}" = "root" ] && user_id=0
	fi
fi

# The alien user uses the system vm
if [ "${user_id}" != 0 -a -L "${gentoo_user_vm}" ]; then
	export ALIEN_DIR=${gentoo_user_vm}
# Otherwise set to the current system vm
elif [ -L ${gentoo_system_vm} ]; then
	export ALIEN_DIR=${gentoo_system_vm}
else
  return
fi

export GSHELL_ROOT=$ALIEN_DIR
export PATH="$ALIEN_DIR/bin/:$PATH"
export LD_LIBRARY_PATH="$ALIEN_DIR/lib/:$LD_LIBRARY_PATH"
export X509_CERT_DIR="$ALIEN_DIR/share/certificates"
export GSHELL_NO_GCC=1
unset gentoo_user_vm gentoo_system_vm user_id
